import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/Home/Home'

function lazyLoadPage(pageName){
	return () => import(`@/pages/${pageName}/${pageName}`);
}


// const originalPush = Router.prototype.push
// Router.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch(err => err)
// }

Vue.use(Router)

export default new Router({
	routes: [
		{
			path: '/',
			name: 'Home',
			component: Home,
			meta: {
				first: true,
				title: '首页'
			}
		},
		{
			path: '/MyMoney',
			name: 'MyMoney',
			component: lazyLoadPage('MyMoney'),
			meta: {
				title: '我的资产'
			},
			children: [
				// 我的资产
				{
					path: '',
					name: 'myBalance',
					meta: {
						title: '我的资产'
					},
					component: () => {return import('@/pages/MyMoney/myBalance/myBalance');}
		        },
				// 资金账户
				{
					path: 'myWallet',
					name: 'myWallet',
					meta: {
						title: '资金账户'
					},
					component: () => {return import('@/pages/MyMoney/myWallet/myWallet');}
		        }
			]
		},
		//简约交易
		{
			path: '/MyProduct',
			name: 'MyProduct',
			component: lazyLoadPage('MyProduct'),
			meta: {
				title: '简约交易'
			},
			children: [
				// 简约交易
				{
					path: '',
					name: 'Product',
					meta: {
						title: '简约交易'
					},
					component: () => {return import('@/pages/MyProduct/Product/Product');}
		        },
				// {
				// 	path: 'myWallet',
				// 	name: 'myWallet',
				// 	meta: {
				// 		title: '资金账户'
				// 	},
				// 	component: () => {return import('@/pages/MyMoney/myWallet/myWallet');}
		  //       }
			]
		},
	]
})

